<?php

/**
 * Description of Question
 *
 * @author fabrice
 */
class Model_Question extends PDO_Mysql {
    
    protected $_name = 'question';
    protected $_primary = 'id_question';

    /**
     * Recupere tout les questions par utilisateur
     * @return <array>
     */
    public function getQuestionByTypeQuestionId($id_type_question) {

        $sql = "SELECT * FROM " . $this->_name ." WHERE id_type_question=" . $id_type_question;
        $result = $this->pquery($sql);
        $row = $this->pfetchAll($result);
        return $row;
    }
    

    /**
     * Insert user_question
     * @param <int> $id_question
     * @param <int> $id_user
     * @return <bool> $row
     */
    public function setQuestion($formData) {

        $sql = 'INSERT INTO ' . $this->_name . ' (id_question,question,id_type_question)' .
                ' VALUES (:id_question,:question,:id_type_question)';
        $data = array(
            ':id_question' => NULL,
            ':question' => $formData['id_user'],
            ':id_type_question' => $formData['id_user_friend']
        );
        $row = $this->pinsert($sql, $data, 'id_question');
        return $row;
    }
}

?>